﻿using System;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework;
using OmegaEngine;

namespace OmegaEngine
{
    // Add some flags in here, like
    // struct flags
    // {
    //      border = true;
    //      something = false;
    // } etc
    //
    // Also, for border, just use x, y, width and height data
    // Dont forget to update GUILabel with StringLength to get width/height

    // Flags for GUI Objects
    public struct GUIFlags
    {
        [Flags]
        public enum borderSidesProperties
        {
            none   = 0,
            left   = 1,
            top    = 2,
            right  = 4,
            bottom = 8,
            all    = 15,
        }

        public bool hasBorder;
        public borderSidesProperties borderSides;

        public GUIFlags(bool HasBorder, GUIFlags.borderSidesProperties BorderSides)
        {
            this.hasBorder = HasBorder;
            this.borderSides = BorderSides;
        }
    }

    // Delegate for value
    public delegate void GUIButtonHandler();

    // Delegate for value
    public delegate string GUIValueHandler();

    public class GUIActor : Component, I2DComponent
    {
        public Rectangle Rectangle { get; set; }
        protected int positionX { get; set; }
        protected int positionY { get; set; }
        protected bool checkInput = false;
        protected GUIFlags flags = new GUIFlags(false, GUIFlags.borderSidesProperties.all);
        Texture2D borderTexure = Engine.Content.Load<Texture2D>("Content/border");

        // Constructors take a position
        public GUIActor()
            : base()
        {
            // Work around for labels
            Setup(new Rectangle(0, 0, 1, 1));
        }

        public GUIActor(GameScreen Parent)
            : base(Parent)
        {
            // Work around for labels
            Setup(new Rectangle(0, 0, 1, 1));
        }

        public GUIActor(int Width, int Height)
            : base()
        {
            Setup(new Rectangle(0, 0, Width, Height));
        }

        public GUIActor(int Width, int Height, GameScreen Parent)
            : base(Parent)
        {
            Setup(new Rectangle(0, 0, Width, Height));
        }

        public GUIActor(Vector2 Dimensions)
            : base()
        {
            Setup(new Rectangle(0, 0, (int)Dimensions.X, (int)Dimensions.Y));
        }

        public GUIActor(Vector2 Dimensions, GameScreen Parent)
            : base(Parent)
        {
            Setup(new Rectangle(0, 0, (int)Dimensions.X, (int)Dimensions.Y));
        }

        public GUIActor(Vector2 Dimensions, int PositionX, int PositionY)
            : base()
        {
            Setup(new Rectangle(PositionX, PositionY, (int)Dimensions.X, (int)Dimensions.Y));
        }

        public GUIActor(Vector2 Dimensions, int PositionX, int PositionY, GameScreen Parent)
            : base(Parent)
        {
            Setup(new Rectangle(PositionX, PositionY, (int)Dimensions.X, (int)Dimensions.Y));
        }

        public GUIActor(int Width, int Height, int PositionX, int PositionY)
            : base()
        {
            Setup(new Rectangle(PositionX, PositionY, Width, Height));
        }

        public GUIActor(int Width, int Height, int PositionX, int PositionY, GameScreen Parent)
            : base(Parent)
        {
            Setup(new Rectangle(PositionX, PositionY, Width, Height));
        }

        public GUIActor(Rectangle Size, GameScreen Parent)
            : base(Parent)
        {
            Setup(new Rectangle((int)Size.X, (int)Size.Y, (int)Size.Width, (int)Size.Height));
        }

        // Provide a method to setup the actor so we don't need to
        // write it in each constructor
        void Setup(Rectangle Rectangle)
        {
            this.positionX = Rectangle.X;
            this.positionY = Rectangle.Y;
            this.Rectangle = Rectangle;
        }

        public override void Draw()
        {
            if (this.flags.hasBorder == true)
            {
                if ((this.flags.borderSides & GUIFlags.borderSidesProperties.bottom) == GUIFlags.borderSidesProperties.bottom)
                {
                    //Engine.SpriteBatch.Draw(this.borderTexure, new Rectangle(
                }

                if ((this.flags.borderSides & GUIFlags.borderSidesProperties.top) == GUIFlags.borderSidesProperties.top)
                {

                }

                if ((this.flags.borderSides & GUIFlags.borderSidesProperties.left) == GUIFlags.borderSidesProperties.left)
                {

                }

                if ((this.flags.borderSides & GUIFlags.borderSidesProperties.right) == GUIFlags.borderSidesProperties.right)
                {

                }
            }
        }
    }
}